<template>
  <div class="register-bg">
    <!-- 轮播背景图片 -->
    <div class="bg-carousel">
      <div 
        v-for="(img, idx) in images"
        :key="img"
        class="bg-img-container"
        :class="{ active: idx === currentImage }"
        :style="{ backgroundImage: `url(${img})` }"
      ></div>
    </div>
    
    <!-- 背景装饰元素 -->
    <div class="bg-decorations">
      <div class="mountain-silhouette"></div>
      <div class="cloud cloud-1"></div>
      <div class="cloud cloud-2"></div>
      <div class="cloud cloud-3"></div>
    </div>

    <div class="register-card">
      <!-- 头像和标题 -->
      <div class="register-header">
        <div class="avatar-container">
          <div class="avatar-ring"></div>
        </div>
        <h1 class="title">
          <span class="title-icon">🏔️</span>
          山行者
          <span class="title-subtitle">Mountain Explorer</span>
        </h1>
        <p class="welcome-text">加入我们，开启您的探险之旅</p>
      </div>
      
      <!-- 注册表单 -->
      <form @submit.prevent="handleRegister" class="register-form">
        <div class="role-group">
          <p class="role-title">选择身份</p>
          <div class="role-options">
            <label class="role-option" :class="{ active: userType === 'user' }">
              <input type="radio" value="user" v-model="userType" />
              <div class="role-card">
                <span class="role-name">游客</span>
                <span class="role-desc">探索旅程</span>
              </div>
            </label>
            <label class="role-option" :class="{ active: userType === 'travel' }">
              <input type="radio" value="travel" v-model="userType" />
              <div class="role-card">
                <span class="role-name">旅行社</span>
                <span class="role-desc">服务提供</span>
              </div>
            </label>
          </div>
        </div>
        
        <div class="form-group">
          <label for="account">
            <span class="label-icon">👤</span>
            账号
          </label>
          <div class="input-wrapper">
            <input
              type="text"
              id="account"
              v-model="account"
              placeholder="请输入账号"
              required
            />
            <div class="input-highlight"></div>
          </div>
        </div>
        <div class="form-group">
          <label for="nickname">
            <span class="label-icon">📝</span>
            昵称
          </label>
          <div class="input-wrapper">
            <input
              type="text"
              id="nickname"
              v-model="nickname"
              placeholder="请输入昵称"
              required
            />
            <div class="input-highlight"></div>
          </div>
        </div>
        <div class="form-group">
          <label for="password">
            <span class="label-icon">🔒</span>
            密码
          </label>
          <div class="input-wrapper">
            <input
              type="password"
              id="password"
              v-model="password"
              placeholder="请输入密码"
              required
            />
            <div class="input-highlight"></div>
          </div>
        </div>
       
        <div class="action-group">
          <button type="submit" class="submit-btn" :disabled="loading || !agreed">
            <span v-if="loading" class="loading-spinner"></span>
            <span class="btn-icon">🚀</span>
            {{ loading ? "注册中..." : "立即注册" }}
          </button>
          <button type="button" class="switch-btn" @click="goLogin">
            <span class="btn-icon">✨</span>
            已有账号？去登录
          </button>
        </div>
        <div class="agreement">
          <label class="checkbox-wrapper">
            <input type="checkbox" v-model="agreed" />
            <span class="checkmark"></span>
            <span class="agreement-text">
              我已阅读并同意
              <a href="#" class="agreement-link">《山行者用户协议》</a>
            </span>
          </label>
        </div>
        <div v-if="error" class="error">
          <span class="error-icon">⚠️</span>
          {{ error }}
        </div>
        <div v-if="success" class="success">
          <span class="success-icon">✅</span>
          {{ success }}
        </div>
      </form>
    </div>
    
    <!-- 轮播指示器 -->
    <div class="carousel-indicators">
      <span 
        v-for="(img, idx) in images" 
        :key="'indicator-'+idx"
        :class="{ active: idx === currentImage }"
        @click="currentImage = idx"
      ></span>
    </div>

    <!-- 底部装饰 -->
    <div class="footer-decoration">
      <div class="wave wave-1"></div>
      <div class="wave wave-2"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: "RegisterPage",
  data() {
    return {
      account: "", // 账号
      nickname: "", // 昵称
      password: "",
      userType: "user", // 默认为普通用户
      regionId: 1, // 默认地区ID
      agreed: false,
      loading: false,
      error: "",
      success: "",
      images: [
        "https://img2.baidu.com/it/u=814251991,938110661&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800", 
        "https://pic.rmb.bdstatic.com/bjh/bb9194b2571d/250226/24b53766fa49abca3e8a6c500825a5e0.jpeg", 
        "https://b0.bdstatic.com/17ff189d26bf5b51597f294e5a9f0ec0.jpg@h_1280", 
        "https://img0.baidu.com/it/u=4066847688,3154080597&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800"  
      ],
      currentImage: 0,
      carouselTimer: null
    };
  },
  mounted() {
    this.startCarousel();
    window.addEventListener('resize', this.setVH);
    this.setVH();
    this.$nextTick(() => {
      document.querySelector('.bg-img-container').classList.add('active');
    });
  },
  beforeDestroy() {
    clearInterval(this.carouselTimer);
    window.removeEventListener('resize', this.setVH);
  },
  methods: {
    startCarousel() {
      if (this.carouselTimer) {
        clearInterval(this.carouselTimer);
      }
      this.carouselTimer = setInterval(() => {
        this.currentImage = (this.currentImage + 1) % this.images.length;
      }, 3000);
    },
    setVH() {
      document.documentElement.style.setProperty('--vh', `${window.innerHeight * 0.01}px`);
    },
    async handleRegister() {
      this.error = "";
      this.success = "";
      if (!this.agreed) {
        this.error = "请先同意《山行者用户注册协议》";
        return;
      }
      this.loading = true;
      try {
        const checkResponse = await fetch(`http://localhost:8080/api/auth/checkUsername?username=${this.account}`, {
            method: "GET",
            headers: {
                "Content-Type": "application/json",
            }
        });
        const checkResult = await checkResponse.json();
        if (checkResult) {
            this.error = "用户名已存在，请选择其他用户名";
            this.loading = false;
            return;
        }

        let endpoint = "";
        let requestBody = {};
        const uniqueId = this.generateUniqueId();

        if (this.userType === "travel") {
            endpoint = "/mw/travelAgency/insert";
            requestBody = {
                travelAgencyId: uniqueId,
                travelAgencyName: this.nickname,
                password: this.password,
                regionId: this.regionId,
                loginName: this.account
            };
        } else {
            endpoint = "/mw/user/insert";
            requestBody = {
                userId: uniqueId,
                userName: this.nickname,
                password: this.password,
                loginName: this.account
            };
        }
        
        const response = await fetch(`http://localhost:8080${endpoint}`, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
            },
            body: JSON.stringify(requestBody)
        });
        
        if (!response.ok) {
            throw new Error("注册失败，服务器返回错误状态");
        }
        
        const result = await response.json();
        
        if (result > 0) {
            this.success = "注册成功！";
            setTimeout(() => {
                this.$router.push("/LoginPage");
            }, 1500);
        } else {
            this.error = "注册失败，请稍后重试";
        }
    } catch (e) {
        this.error = e.message || "注册失败，请检查网络连接";
        console.error("注册错误:", e);
    } finally {
        this.loading = false;
    }
},
    generateUniqueId() {
      return Math.floor(100000 + Math.random() * 900000);
    },
    goLogin() {
      this.$router.push("/LoginPage");
    }
  }
};
</script>

<style scoped>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
  --vh: 1vh;
  --primary-color: #8a4fff; /* 修改为主色调为紫色 */
  --secondary-color: #ff6b9d; /* 修改为粉色作为辅助色 */
  --accent-color: #6e45e2; /* 修改为深紫色作为强调色 */
  --text-dark: #2c3e50;
  --text-light: #7f8c8d;
  --bg-white: rgba(255, 255, 255, 0.98);
  --shadow-light: 0 10px 30px rgba(138, 79, 255, 0.1); /* 调整为紫色阴影 */
  --shadow-medium: 0 15px 40px rgba(138, 79, 255, 0.15);
  --shadow-heavy: 0 20px 60px rgba(138, 79, 255, 0.2);
}

* {
  box-sizing: border-box;
}

.register-bg {
  min-height: calc(var(--vh, 1vh) * 100);
  width: 100vw;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  font-family: 'Poppins', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* 背景轮播 */
.bg-carousel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 0;
}

.bg-img-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 2s ease-in-out;
  will-change: opacity;
}

.bg-img-container.active {
  opacity: 1;
}

.bg-img-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(138, 79, 255, 0.4); /* 修改为淡淡的紫色遮罩层 */
}

/* 背景装饰元素 */
.bg-decorations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1;
}

.mountain-silhouette {
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 100%;
  height: 200px;
  background: linear-gradient(to top,
      rgba(44, 90, 160, 0.7) 0%,
      rgba(44, 90, 160, 0.4) 50%,
      transparent 100%);
  clip-path: polygon(0 100%, 0 60%, 15% 40%, 25% 50%, 35% 30%, 45% 45%, 55% 25%, 65% 40%, 75% 20%, 85% 35%, 100% 15%, 100% 100%);
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50px;
  opacity: 0.8;
  animation: float 20s infinite ease-in-out;
}

.cloud:before,
.cloud:after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50px;
}

.cloud-1 {
  width: 80px;
  height: 30px;
  top: 20%;
  left: 10%;
  animation-delay: 0s;
}

.cloud-1:before {
  width: 50px;
  height: 50px;
  top: -25px;
  left: 10px;
}

.cloud-1:after {
  width: 60px;
  height: 40px;
  top: -15px;
  right: 10px;
}

.cloud-2 {
  width: 60px;
  height: 25px;
  top: 15%;
  right: 20%;
  animation-delay: -5s;
}

.cloud-2:before {
  width: 40px;
  height: 40px;
  top: -20px;
  left: 5px;
}

.cloud-2:after {
  width: 45px;
  height: 35px;
  top: -12px;
  right: 5px;
}

.cloud-3 {
  width: 70px;
  height: 28px;
  top: 25%;
  left: 70%;
  animation-delay: -10s;
}

.cloud-3:before {
  width: 45px;
  height: 45px;
  top: -22px;
  left: 8px;
}

.cloud-3:after {
  width: 55px;
  height: 38px;
  top: -14px;
  right: 8px;
}

@keyframes float {
  0%,
  100% {
    transform: translateX(0) translateY(0);
  }

  25% {
    transform: translateX(20px) translateY(-10px);
  }

  50% {
    transform: translateX(-10px) translateY(-20px);
  }

  75% {
    transform: translateX(15px) translateY(-5px);
  }
}

/* 注册卡片 */
.register-card {
  position: relative;
  z-index: 2;
  background: var(--bg-white);
  border-radius: 24px;
  box-shadow: var(--shadow-heavy);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 460px;
  min-width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(25px);
  transform: translateZ(0);
  transition: all 0.4s ease;
  overflow: hidden;
}

.register-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color), var(--secondary-color));
  border-radius: 24px 24px 0 0;
}

.register-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 25px 80px rgba(138, 79, 255, 0.25);
}

/* 头部样式 */
.register-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.avatar-container {
  position: relative;
  display: inline-block;
  margin-bottom: 1.5rem;
}

.avatar-ring {
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border: 2px solid transparent;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color)) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: rotate 8s linear infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.title {
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 0.5rem 0;
  letter-spacing: 2px;
  position: relative;
}

.title-icon {
  font-size: 2rem;
  margin-right: 0.5rem;
  display: inline-block;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-8px);
  }

  60% {
    transform: translateY(-4px);
  }
}

.title-subtitle {
  display: block;
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--text-light);
  letter-spacing: 1px;
  margin-top: 0.3rem;
}

.welcome-text {
  font-size: 1rem;
  color: var(--text-light);
  margin: 0;
  font-weight: 300;
  letter-spacing: 0.5px;
}

/* 表单样式 */
.register-form {
  display: flex;
  flex-direction: column;
}

.form-group {
  margin-bottom: 1.8rem;
}

.form-group label {
  display: flex;
  align-items: center;
  font-size: 1.1rem;
  color: var(--text-dark);
  font-weight: 500;
  margin-bottom: 0.8rem;
  letter-spacing: 0.5px;
}

.label-icon {
  margin-right: 0.5rem;
  font-size: 1.2rem;
}

.input-wrapper {
  position: relative;
}

.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  padding: 1rem 1.2rem;
  border: 2px solid rgba(138, 79, 255, 0.2);
  border-radius: 12px;
  font-size: 1.1rem;
  transition: all 0.3s ease;
  outline: none;
  background: rgba(248, 251, 255, 0.95);
  color: var(--text-dark);
  font-weight: 400;
}

.form-group input:focus {
  border-color: var(--primary-color);
  background: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(138, 79, 255, 0.15);
}

.input-highlight {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
  transition: width 0.3s ease;
  border-radius: 1px;
}

.form-group input:focus+.input-highlight {
  width: 100%;
}

/* 角色选择 */
.role-group {
  margin-bottom: 2rem;
}

.role-title {
  font-size: 1.1rem;
  color: var(--text-dark);
  font-weight: 500;
  margin-bottom: 1rem;
  text-align: center;
  letter-spacing: 0.5px;
}

.role-options {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

.role-option {
  flex: 1;
  cursor: pointer;
}

.role-option input[type="radio"] {
  display: none;
}

.role-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.2rem 0.8rem;
  border: 2px solid rgba(138, 79, 255, 0.2);
  border-radius: 16px;
  background: rgba(248, 251, 255, 0.9);
  transition: all 0.3s ease;
  cursor: pointer;
  text-align: center;
}

.role-option.active .role-card {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, rgba(138, 79, 255, 0.15), rgba(110, 69, 226, 0.15));
  transform: translateY(-3px);
  box-shadow: var(--shadow-medium);
}

.role-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.2rem;
  display: block;
}

.role-desc {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 300;
}

.role-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-light);
}

/* 按钮样式 */
.action-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.submit-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: 600;
  padding: 1rem 0;
  box-shadow: var(--shadow-medium);
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.submit-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.submit-btn:hover::before {
  left: 100%;
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-heavy);
}

.submit-btn:disabled {
  background: linear-gradient(135deg, #bdc3c7, #95a5a6);
  cursor: not-allowed;
  transform: none !important;
  box-shadow: var(--shadow-light);
}

.switch-btn {
  width: 100%;
  background: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 500;
  padding: 0.9rem 0;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.switch-btn:hover {
  background: var(--primary-color);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

.btn-icon {
  font-size: 1rem;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* 协议复选框 */
.agreement {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
}

.checkbox-wrapper {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-light);
}

.checkbox-wrapper input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(138, 79, 255, 0.3);
  border-radius: 4px;
  margin-right: 0.5rem;
  position: relative;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.checkbox-wrapper input:checked+.checkmark {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.checkbox-wrapper input:checked+.checkmark::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 12px;
  font-weight: bold;
}

.agreement-text {
  line-height: 1.4;
}

.agreement-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.agreement-link:hover {
  text-decoration: underline;
}

/* 错误提示 */
.error {
  color: #e74c3c;
  text-align: center;
  font-weight: 500;
  font-size: 1rem;
  padding: 0.8rem 1rem;
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.error-icon {
  font-size: 1rem;
}

.success {
  color: #28b36a;
  text-align: center;
  font-weight: 500;
  font-size: 1rem;
  padding: 0.8rem 1rem;
  background: rgba(40, 179, 106, 0.1);
  border: 1px solid rgba(40, 179, 106, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.success-icon {
  font-size: 1rem;
}

/* 轮播指示器 */
.carousel-indicators {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 3;
}

.carousel-indicators span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.4s ease;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.carousel-indicators span.active {
  background: rgba(255, 255, 255, 0.95);
  transform: scale(1.3);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.4);
}

.carousel-indicators span:hover {
  background: rgba(255, 255, 255, 0.8);
  transform: scale(1.1);
}

/* 底部装饰 */
.footer-decoration {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100px;
  pointer-events: none;
  z-index: 1;
}

.wave {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120'%3E%3Cpath d='M321.39,56.44C202.5,92.29,133.89,127.75,49.44,125.98C-3.45,125.1-41.53,92.51-70.54,56.44L-70.54,120L1200,120L1200,56.44C1169.24,92.29,1100.63,127.75,1016.18,125.98C963.29,125.1,925.21,92.51,896.2,56.44C867.19,20.37,829.11,-12.26,776.22,-11.38C691.77,-9.61,623.16,26.84,504.27,62.69C385.38,98.54,316.77,134,232.32,132.23C179.43,131.35,141.35,98.76,112.34,62.69C83.33,26.62,45.25,-6.01,-7.64,-5.13C-92.09,-3.36,-160.7,32.09,-279.59,67.94L-279.59,120L1200,120Z' fill='%23ffffff' fill-opacity='0.1'/%3E%3C/svg%3E") no-repeat center bottom;
  background-size: cover;
  opacity: 0.6;
}

.wave-1 {
  animation: wave-animation 15s ease-in-out infinite;
}

.wave-2 {
  animation: wave-animation 20s ease-in-out infinite reverse;
  opacity: 0.3;
}

@keyframes wave-animation {
  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(-20px);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .register-card {
    padding: 2.5rem 2rem;
    max-width: 95vw;
    margin: 0 10px;
  }

  .title {
    font-size: 2.2rem;
  }

  .role-options {
    flex-direction: column;
    gap: 1rem;
  }

  .role-card {
    padding: 1rem;
  }

  .action-group {
    gap: 0.8rem;
  }

  .cloud {
    display: none;
  }

  .carousel-indicators {
    bottom: 20px;
  }
}

@media (max-width: 480px) {
  .register-card {
    padding: 2rem 1.5rem;
    border-radius: 20px;
  }

  .title {
    font-size: 2rem;
    letter-spacing: 1px;
  }

  .title-icon {
    font-size: 1.5rem;
  }

  .form-group input[type="text"],
  .form-group input[type="password"] {
    padding: 0.9rem 1rem;
    font-size: 0.95rem;
  }

  .role-card {
    padding: 0.8rem;
  }

  .role-name {
    font-size: 0.85rem;
  }

  .role-desc {
    font-size: 0.7rem;
  }

  .submit-btn,
  .switch-btn {
    padding: 0.8rem 0;
    font-size: 1rem;
  }

  .carousel-indicators {
    bottom: 15px;
  }

  .carousel-indicators span {
    width: 10px;
    height: 10px;
  }
}

@media (max-width: 360px) {
  .register-card {
    padding: 1.5rem 1rem;
  }

  .title {
    font-size: 1.8rem;
  }

  .welcome-text {
    font-size: 0.9rem;
  }

  .mountain-silhouette {
    height: 120px;
  }
}

/* 高分辨率屏幕适配 */
@media (min-width: 1200px) {
  .register-card {
    max-width: 500px;
    padding: 3.5rem 3rem;
  }

  .title {
    font-size: 3rem;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-white: rgba(30, 30, 30, 0.95);
    --text-dark: #ecf0f1;
    --text-light: #bdc3c7;
  }

  .register-card {
    background: var(--bg-white);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .form-group input[type="text"],
  .form-group input[type="password"] {
    background: rgba(60, 60, 60, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-dark);
  }

  .form-group input:focus {
    background: rgba(60, 60, 60, 0.9);
  }

  .role-card {
    background: rgba(60, 60, 60, 0.6);
    border-color: rgba(255, 255, 255, 0.2);
  }

  .role-option.active .role-card {
    background: rgba(138, 79, 255, 0.3);
  }
}

/* 打印样式 */
@media print {
  .register-bg {
    background: white !important;
  }

  .bg-carousel,
  .bg-decorations,
  .carousel-indicators,
  .footer-decoration {
    display: none !important;
  }

  .register-card {
    box-shadow: none !important;
    border: 2px solid #ccc !important;
  }
}

/* 无障碍访问 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .cloud {
    animation: none !important;
  }

  .avatar-ring {
    animation: none !important;
  }

  .title-icon {
    animation: none !important;
  }
}

/* 焦点可见性 */
.submit-btn:focus-visible,
.switch-btn:focus-visible,
.form-group input:focus-visible,
.role-card:focus-visible,
.carousel-indicators span:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  .register-card {
    border: 3px solid var(--text-dark);
  }

  .form-group input[type="text"],
  .form-group input[type="password"] {
    border-width: 3px;
  }

  .role-card {
    border-width: 3px;
  }
}
</style>